package com.rookie.im.domain.enums;

import lombok.Getter;

@Getter
public enum CommandType {

    USER("4"),
    FRIEND("3"),
    GROUP("2"),
    MESSAGE("1"),
    SYSTEM("9");

    private final String commandType;
    CommandType(String commandType) {
        this.commandType = commandType;
    }
    public static CommandType genCommandType(int command) {
        String flag = String.valueOf(command).substring(0, 1);
        for (int i = 0, length = CommandType.values().length; i < length; ++i) {
            if (CommandType.values()[i].getCommandType().equals(flag)) {
                return CommandType.values()[i];
            }
        }
        return MESSAGE;
    }
}
